import java.util.Scanner;
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: a1227
 * Date: 2022-10-10
 * Time: 10:12
 */
//JAVA23 定义打印方法——https://www.nowcoder.com/practice/50b50ae39d65415a9fd70601d711e5af?tpId=220&tqId=2114415&ru=/exam/oj&qru=/ta/primary-grammar-java/question-ranking&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26tab%3D%25E8%25AF%25AD%25E6%25B3%2595%25E7%25AF%2587%26topicId%3D220
/*
class First{
    public String toString(){
        return "First";
    }
}

class Second{
    public String toString(){
        return "Second";
    }
}

class Third{
    public String toString(){
        return "Third";
    }
}

public class Test {
    public static void print(Object obj){
        System.out.println(obj.toString());
    }

    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            String str = in.next();
            print(Class.forName(str).newInstance());
        }
    }
}
*/

//JAVA24 类型判断——https://www.nowcoder.com/practice/97223208ca954e67832da716b46e5d72?tpId=220&tqId=2113902&ru=/exam/oj&qru=/ta/primary-grammar-java/question-ranking&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26tab%3D%25E8%25AF%25AD%25E6%25B3%2595%25E7%25AF%2587%26topicId%3D220
/*
class Base{

}

class Sub1 extends Base{

}

class Sub2 extends Base{

}

public class Test{
    public static void getClassName(Object base){
        if(base instanceof Sub1){
            System.out.println("Sub1");
            return ;
        }
        if(base instanceof Sub2){
            System.out.println("Sub2");
            return ;
        }
        if(base instanceof Base){
            System.out.println("Base");
            return ;
        }
    }
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String str = in.nextLine();
            getClassName((Base)Class.forName(str).newInstance());
        }
    }
}
*/

